﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:BadHabit_Factory="clr-namespace:BadHabit.Factory"  
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools"
    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    
    xmlns:props="clr-namespace:BadHabit.Factory.Properties"
    
    >


    <Style x:Key="TopMenu_Separator"  TargetType="Separator">
        <Setter Property="Height" Value="1"/>
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Separator">                    
                    <Border BorderBrush="{StaticResource TopMenuBorderBrush}" BorderThickness="1" Margin="0" Padding="0"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TopLevelHeader -->        
    <ControlTemplate x:Key="TopMenu_TopLevelHeader" TargetType="MenuItem">
        <Border Name="Border" CornerRadius="5,5,5,5" BorderThickness="1,1,1,0" BorderBrush="Transparent" Margin="0,2,3,0" Cursor="Hand">
            <Grid>
                <ContentPresenter Margin="5,2,5,2" ContentSource="Header" RecognizesAccessKey="True" Cursor="Hand"/>
                <Popup 
                    Name="Popup"
                    Placement="Bottom"                        
                    IsOpen="{TemplateBinding IsSubmenuOpen}"
                    AllowsTransparency="True" 
                    Focusable="False"
                    PopupAnimation="Fade"                        
                    HorizontalOffset="-1"
                    >
                    <Border Margin="0,0,5,5" 
                  Name="SubmenuBorder"                              
                  Background="{StaticResource TopMenuPopupBrush}"
                  BorderBrush="{StaticResource TopMenuBorderBrush}"
                  BorderThickness="1,0,1,1">
                        <StackPanel  IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                        <Border.BitmapEffect>
                            <DropShadowBitmapEffect Color="Black" Direction="300" Opacity="0.3" ShadowDepth="3" Softness="0.1" PresentationOptions:Freeze="True"/>
                        </Border.BitmapEffect>

                    </Border>
                </Popup>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation" Value="true">
                <Setter TargetName="Popup" Property="PopupAnimation" Value="None"/>
            </Trigger>
            <Trigger Property="IsSubmenuOpen" Value="true">
                <Setter TargetName="Border" Property="CornerRadius" Value="5,5,0,0"/>                
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">                
                <Setter TargetName="Border" Property="Background" Value="{StaticResource TopMenuPopupBrush}"/>                
                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource TopMenuBorderBrush}"/>
            </Trigger>
            <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="True">
                <Setter TargetName="SubmenuBorder" Property="CornerRadius" Value="0,5,5,5"/>
                <Setter TargetName="SubmenuBorder" Property="Padding" Value="0,0,0,0"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False" SourceName="Border">
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
        
    <!-- TopLevelItem -->
    <ControlTemplate x:Key="TopMenu_TopLevelItem" TargetType="MenuItem">
        <Border Name="Border" CornerRadius="5,5,5,5" BorderThickness="1,1,1,1" BorderBrush="Transparent" Margin="0,2,3,0" Cursor="Hand">
            <Grid>
                <ContentPresenter Margin="5,4,5,2" ContentSource="Header" RecognizesAccessKey="True" Cursor="Hand" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter TargetName="Border" Property="Background"  Value="{StaticResource TopMenuPopupBrush}"/>
                <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource TopMenuBorderBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False" SourceName="Border">
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- SubmenuItem -->
    <ControlTemplate x:Key="TopMenu_SubmenuItem" TargetType="MenuItem">
        
        <Border Name="Border" Cursor="Hand">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="22" SharedSizeGroup="Icon"/>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
                    <ColumnDefinition Width="13"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter
                    Grid.Column="0"
                    Name="Icon" Margin="5,0,0,0" VerticalAlignment="Center" ContentSource="Icon"/>
                <Border 
                        Name="Check"  
                        Width="13" Height="13" 
                        Visibility="Collapsed"
                        Margin="6,0,6,0" 
                        Background="{StaticResource TopMenuPopupBrush}"
                        BorderThickness="1"
                        BorderBrush="{StaticResource TopMenuPopupBrush}">
                    <Path 
                          Name="CheckMark"
                          Width="7" Height="7" 
                          Visibility="Hidden" 
                          SnapsToDevicePixels="False" 
                          Stroke="Black"
                          StrokeThickness="2"
                          Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                </Border>
                <ContentPresenter                    
                    Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" Margin="5,5,0,5" Cursor="Hand"/>                                            
                <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,2,0,2" DockPanel.Dock="Right" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>            
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsCheckable" Value="true">
                <Setter TargetName="Check" Property="Visibility" Value="Visible"/>
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Border" Property="Background" Value="{StaticResource TopMenuSelectedBackgroundBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource TopMenuSelectedForegroundBrush}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false" SourceName="Border">
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>                
            </Trigger>
            
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- SubmenuHeader -->
    <ControlTemplate 
  x:Key="TopMenu_SubmenuHeader" 
  TargetType="MenuItem">
        <Border Name="Border" Cursor="Hand">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
                    <ColumnDefinition Width="13"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter 
        Name="Icon"
        Margin="6,0,6,0"
        VerticalAlignment="Center"
        ContentSource="Icon"/>
                <ContentPresenter 
        Name="HeaderHost"
        Grid.Column="1"
        ContentSource="Header"
        RecognizesAccessKey="True"/>
                <TextBlock x:Name="InputGestureText"
        Grid.Column="2"
        Text="{TemplateBinding InputGestureText}"
        Margin="5,5,2,2"
        DockPanel.Dock="Right"/>
                <Path 
        Grid.Column="3"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Data="M 0 0 L 0 7 L 4 3.5 Z" 
        Fill="Black" />
                <Popup 
        Name="Popup"
        Placement="Right"
        HorizontalOffset="-4" 
        IsOpen="{TemplateBinding IsSubmenuOpen}"
        AllowsTransparency="True" 
        Focusable="False"
        PopupAnimation="Fade">
                    <Border 
          Name="SubmenuBorder"
          SnapsToDevicePixels="True"
          Background="{StaticResource TopMenuPopupBrush}"
          BorderBrush="{StaticResource TopMenuBorderBrush}"
          BorderThickness="1" >
                        <StackPanel  
            IsItemsHost="True" 
            KeyboardNavigation.DirectionalNavigation="Cycle" />
                    </Border>
                </Popup>
            </Grid>


        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Border" Property="Background"
              Value="{StaticResource TopMenuSelectedBackgroundBrush}"/>
            </Trigger>
            <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="True">
                <Setter TargetName="SubmenuBorder" Property="CornerRadius" Value="4"/>
                <Setter TargetName="SubmenuBorder" Property="Padding" Value="0,3,0,3"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- Top MenuItem Style -->
    <Style x:Key="TopMenuItem" TargetType="MenuItem">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="{StaticResource DarkTextBrush}"/>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource TopMenu_TopLevelHeader}"/>
                <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource TopMenu_TopLevelItem}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource TopMenu_SubmenuHeader}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource TopMenu_SubmenuItem}"/>
            </Trigger>
        </Style.Triggers>
    </Style>


    <Style x:Key="TopMenu_SubmenuItemContainerStyle" TargetType="MenuItem">
        <Setter Property="Template" Value="{StaticResource TopMenu_SubmenuItem}"/>
    </Style>



    <Style x:Key="TopMenu" TargetType="Menu">
        <Setter Property="Background" Value="{StaticResource TopMenuBrush}"/>
        <Setter Property="Foreground" Value="{StaticResource DarkTextBrush}"/>        
    </Style>

    <!-- TOOL BAR MENU -->
    <Style x:Key="{x:Static ToolBar.MenuStyleKey}" TargetType="Menu">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Padding" Value="0"/>
    </Style>
    
       
    <!-- TopLevelHeader -->
    <ControlTemplate x:Key="ToolBarMenu_TopLevelHeader" TargetType="MenuItem">        
        <Grid x:Name="grid">
            <Border
                x:Name="border"
                MinWidth="60"
                MinHeight="40"
                MaxWidth="100"
                Style="{StaticResource HighLightBorder}"                            
              
                BorderThickness="1"
                Padding="0"
                CornerRadius="5">
                
                 
                    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Border
                            x:Name="label"
                            Grid.Row="1"                                        
                            Margin="0,0,0,0"
                            Background="Transparent"                                                       
                            BorderThickness="1"
                            CornerRadius="0,0,5,5"
                            Padding="2,1,2,1">
                            <ContentPresenter                                                
                                Grid.Row="1"
                                OverridesDefaultStyle="True"
                                TextBlock.FontFamily="{StaticResource BasicFont}"
                                TextBlock.FontSize="{StaticResource BasicFontSize}"
                                TextBlock.Foreground="{StaticResource DarkTextBrush}"
                                 
                                x:Name="PrimaryContent"
                                HorizontalAlignment="Center" VerticalAlignment="Center"
                                Margin="0" 
                                Content="{TemplateBinding Header}" />
                        </Border>                        
                        
                        <ContentPresenter Grid.Row="0" Name="Icon" Margin="0" VerticalAlignment="Center" ContentSource="Icon"/>


                    </Grid>


                
            </Border>
            <Popup 
                Name="Popup"
                Placement="Bottom"                        
                StaysOpen="True"               
                IsOpen="{TemplateBinding IsSubmenuOpen}"
                AllowsTransparency="True" 
                Focusable="False"
                PopupAnimation="Fade">
                <Border
                    Margin="5,5,5,5"
                    CornerRadius="5,5,5,5"
                    Name="SubmenuBorder"                              
                    Background="{StaticResource FormInputBackgroundBrush}"
                    BorderBrush="{StaticResource DarkTextBrush}"
                    BorderThickness="1,1,1,1">
                    <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                    <Border.BitmapEffect>
                        <DropShadowBitmapEffect Color="Black" Direction="300" Opacity="0.3" ShadowDepth="3" Softness="0.1" PresentationOptions:Freeze="True"/>
                    </Border.BitmapEffect>
                </Border>
            </Popup>
        </Grid>
        
        <ControlTemplate.Triggers>                        
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
                <Setter TargetName="border" Property="Border.Opacity" Value="0.5"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="True">                                
                <Setter TargetName="label" Property="Border.Background" Value="{StaticResource AlertBackgroundBrush}"/>
                <Setter TargetName="label" Property="Border.BorderBrush" Value="{StaticResource AlertBrush}"/>                
                <Setter TargetName="PrimaryContent" Property="TextBlock.Foreground" Value="{StaticResource AlertBrush}"/>
            </Trigger>
            <Trigger SourceName="border" Property="Border.IsMouseOver" Value="True">
                <Setter TargetName="label" Property="Border.Background" Value="{StaticResource SelectedItemBrush}"/>
                <Setter TargetName="PrimaryContent" Property="TextBlock.Foreground" Value="{StaticResource DarkTextBrush}"/>         
            </Trigger>            
        </ControlTemplate.Triggers>

    </ControlTemplate>

    <ControlTemplate x:Key="ToolBarMenu_SubMenuItem" TargetType="MenuItem">
        <Border Style="{StaticResource HighLightBorder}">       
                <StackPanel Orientation="Horizontal" Cursor="Hand" >
                <ContentPresenter ContentSource="Icon" Margin="0,0,2,0" />
                <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" />
                <ContentPresenter ContentSource="InputGestureText" Margin="30,0,0,0" RecognizesAccessKey="True" />                    
                </StackPanel>
            </Border>        
    </ControlTemplate>



    <!-- Top MenuItem Style -->
    <Style x:Key="ToolBarMenuItem" TargetType="MenuItem">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Foreground" Value="{StaticResource DarkTextBrush}"/>                        
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="MenuItem">
                    <Setter Property="Template" Value="{StaticResource ToolBarMenu_SubMenuItem}"/>
                </Style>
            </Setter.Value>
        </Setter>                
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelHeader}"/>
                <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_TopLevelHeader}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource ToolBarMenu_SubMenuItem}"/>
            </Trigger>           
        </Style.Triggers>
    </Style>

   


    <!-- ADD TASKS MENU ITEMS -->
    
    <MenuItem
        x:Key="AddProjectTaskMenuItem" x:Shared="False"        
        Header="{x:Static props:Resources.PROJECT_TASK}" Command="BadHabit_Factory:FactoryCommands.AddTask"  CommandParameter="0">
        <MenuItem.Icon>
            <Image Source="/Images/TaskType/16x16/PROJECT_TASK.png" Width="16" Height="16" Stretch="Uniform"/>
        </MenuItem.Icon>
    </MenuItem>
    <MenuItem
        x:Key="AddTestTaskMenuItem" x:Shared="False"
        Header="{x:Static props:Resources.TEST_TASK}" Command="BadHabit_Factory:FactoryCommands.AddTask" CommandParameter="3">
        <MenuItem.Icon>
            <Image Source="/Images/TaskType/16x16/PROJECT_TASK.png" Width="16" Height="16" Stretch="Uniform"/>
        </MenuItem.Icon>
    </MenuItem>
    <MenuItem 
        x:Key="AddBugMenuItem" x:Shared="False"
        Header="{x:Static props:Resources.DEVELOPING_BUG}" Command="BadHabit_Factory:FactoryCommands.AddTask"  CommandParameter="1">
        <MenuItem.Icon>
            <Image Source="/Images/TaskType/16x16/DEVELOPING_BUG.png" Width="16" Height="16" Stretch="Uniform"/>
        </MenuItem.Icon>
    </MenuItem>
    <MenuItem 
        x:Key="AddAfterDeployBugMenuItem" x:Shared="False"
        Header="{x:Static props:Resources.AFTER_DELIVERY_BUG}" Command="BadHabit_Factory:FactoryCommands.AddTask"  CommandParameter="2">
        <MenuItem.Icon>
            <Image Source="/Images/TaskType/16x16/AFTER_DELIVERY_BUG.png" Width="16" Height="16" Stretch="Uniform"/>
        </MenuItem.Icon>
    </MenuItem>    
    <MenuItem
        x:Key="AddImpedimentMenuItem" x:Shared="False"
        Header="{x:Static props:Resources.IMPEDIMENT}" Command="BadHabit_Factory:FactoryCommands.AddTask" CommandParameter="4">
        <MenuItem.Icon>
            <Image Source="/Images/TaskType/16x16/IMPEDIMENT.png" Width="16" Height="16" Stretch="Uniform"/>
        </MenuItem.Icon>
    </MenuItem>



</ResourceDictionary>